<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="../../lib/html5shiv.js?rev=@@hash"></script>
    <script type="text/javascript" src="../../lib/respond.min.js?rev=@@hash"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="../../static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="../../static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="../../lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="../../static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="../../static/h-ui.admin/css/style.css" />
    <link rel="stylesheet" type="text/css" href="../../ht-css/Project.css" />
    <link rel="stylesheet" type="text/css" href="../../lib/Validform/5.3.2/style.css" />
    <!--[if IE 6]>
    <script type="text/javascript" src="../../lib/DD_belatedPNG_0.0.8a-min.js?rev=@@hash"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="../../ht-css/style-q.css" />
    <link rel="stylesheet" href="../../ht-css/replaceAddress/addAddress.css">
    <style>
        .quyuss{ cursor:pointer }
        .Hui-iconfont{ cursor:pointer }
    </style>
    <title>商品设置</title>
</head>
<body data-id="">
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页  <span class="c-gray en">&gt;</span>方盛云仓<span class="c-gray en">&gt;</span>云仓管理<span class="c-gray en">&gt;</span>商品设置<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<article class="page-container">
    <form class="ml-20 mr-20" id="form-member-add" method="post">

        <div class="bg-1 bk-gray pd-20 mb-20">
            <div class="pd-20 mb-20">
                <table>
                    <tr>
                        <td class="col-3-l"><span class="f-l">方盛云仓名称：</span><span id="house_name"></span></td>
                        <td class="col-3-1"><span class="f-l">方盛云仓ID：</span><span id="house_id"></span></td>
                        <td class="col-3-1"><span class="f-l" id="alsi">状态：</span><span id="status"></span></td>
                    </tr>
                    <tr>
                        <td class="col-3-1"><span class="f-l">客户名称：</span><span id="coustomerName"></span></td>
                        <td class="col-3-1"><span class="f-l">客户归属：</span><span id="group_name"></span></td>
                        <td class="col-3-1"><span class="f-l">客户ID：</span><span id="coustomerId"></span></td>
                    </tr>
                    <tr>
                        <td class="col-3-1"><span class="f-l">权限账号：</span><span id="loginAccount"></span></td>
                    </tr>
                </table>
            </div>

            <div class="va-m lh-20 f-14 pb-15">
                <strong><span class="c-red pr-5 f-l">*</span>指定价格省份</strong>
            </div>
            <div class="line"></div>
            <div class="pd-20 mb-20">
                <table>
              <!--      <select class="select " style="height:26px;width: 120px" name="final_sent" id="getArea" size="1">
                        <option value="">请选择指定区域价</option>
                    </select>-->
                    <div class="formControls col-xs-8 col-sm-6">
                    <input type="text"  class="input-text radius" onkeyup="seachprovicnsfn(this)"  placeholder="请选指定价格省份" id="fen_lsit" style="width: 150px" autocomplete="off">
                    <ul class="relation radius guanlian" id="getArea" style="margin-top: -9px;">
                        <li class="quyuss">请选择指定价格省份</li>
                    </ul>
                    <input type="button" style=" margin-left: 26px;margin-top: -2px;"  class="btn btn-secondary radius size-S " onclick="quyu()" value="确定">
                    </div>
                </table>
            </div>
            <div class="line"></div>
            <div class="pd-20 mb-20">

            </div>
            <div class="va-m lh-20 f-14 pb-15">
                <strong><span class="c-red pr-5 f-l">*</span>商品设置</strong> <input type="button"  class="btn btn-secondary radius size-S " onclick="tiao('添加商品','addgoods.html')" style="margin-left: 51px;" value="添加商品"><a id="daochu" href=""  class="btn  radius size-S " onclick="exportcode()" style="margin-left: 51px;">商品导出</a>
                <input type="text" class="input-text radius" id="goodscode"  style="margin-left: 244px; width: 129px;" placeholder="请输入商品code"> <input type="button" style=" margin-left: 26px;margin-top: -2px;"  class="btn btn-secondary radius size-S " onclick="querycode(1)" value="查询"> <input type="button" style=" margin-left: 26px;margin-top: -2px;"  class="btn btn-secondary radius size-S " onclick="querycode(2)" value="重置">
                <input type="button"  class="btn btn-secondary radius size-S " onclick="viewItem()" style="margin-left: 51px;" value="查看低下限商品"><a id="exportGood" href=""  class="btn btn-secondary radius size-S " onclick="exportGoods()" style="margin-left: 27px;">导出低下限商品</a>
            </div>
            <div class="pd-20 mb-20">
                 共<span id="sp">0</span>个商品
                <table class="table table-border table-bordered table-hover table-bg table-sort mt-10" id="datatable">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>商品编码</th>
                        <th>图片</th>
                        <th>商品名称</th>
                        <th>规格属性</th>
                        <th>品牌</th>
                        <th>售价</th>
                        <th>计量单位</th>
                        <th>可用库存</th>
                        <th>总库存</th>
                        <th>仓位</th>
                        <th>更新时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody class="shun">
                    </tbody>
                </table>
                <div class="mt-40"></div>
                <div class="dataTables_wrapper goods_fanye clearfix mt-5">
                    <div class="f-r pageturning M-box3"></div>
                </div>
            </div>
            <input type="button" onclick="cancelB()"  class="btn btn-secondary radius size-S " style="margin-left: 603px;" value="返回">
        </div>
    </form>
</article>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="../../lib/jquery/1.9.1/jquery.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../lib/layer/2.4/layer.js?rev=@@hash"></script>
<script type="text/javascript" src="../../static/h-ui/js/H-ui.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../static/h-ui.admin/js/H-ui.admin.js?rev=@@hash"></script> <!--/_footer 作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="../../lib/My97DatePicker/4.8/WdatePicker.js?rev=@@hash"></script>
<!--表单验证-->
<script type="text/javascript" src="../../lib/jquery.validation/1.14.0/jquery.validate.js?rev=@@hash"></script>
<script type="text/javascript" src="../../lib/jquery.validation/1.14.0/validate-methods.js?rev=@@hash"></script>
<script type="text/javascript" src="../../lib/jquery.validation/1.14.0/messages_zh.js?rev=@@hash"></script>
<script type="text/javascript" src="../../lib/Validform/5.3.2/Validform_v5.3.2_min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../lib/datatables/1.10.0/jquery.dataTables.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../lib/laypage/1.2/laypage.js?rev=@@hash"></script>
<script src="../../ht-js/public.js?rev=@@hash"></script>
<!--验证token-->
<script src="../../ht-js/verifyToken.js?rev=@@hash"></script>
<script src="../../ht-js/Project.js?rev=@@hash"></script>
<!--权限控制-->
<!--引入分页-->
<link rel="stylesheet" href="../../lib/pagination/pagination.css">
<script src="../../lib/pagination/jquery.pagination.js?rev=@@hash"></script>
<script type="text/javascript" src="../../ht-js/power.js?rev=@@hash"></script>
<script type="text/javascript" src="../../ht-js/address.demo.js"></script>
<script>
var pl=""
var codeid=""
var xuanzhong=0

    //动态区域
    dongtai()
    function dongtai(keyword) {
        $.ajax({
            contentType: "application/json;charset=UTF-8",
            url:root.sroreinter.getAddressByMainAddressList,
            cache: false, //禁用缓存
            type: "POST",
            dataType:"json",
            async:false,//优先运行
            data: JSON.stringify({
                addressCode:"",
                addressCodes:[],
                parentAddressCode:"",
                parentAddressCodes:[],
                addressLevels:['101'],
                addressNameLike:keyword,//模糊搜索关键字
                pageSize:1000,
                pageNum:1

            }),
            success: function (data) {
                console.log(data)
                var optionstring = "";
                if(data.data.length >0){
                    for(var i=0;i<data.data.length;i++){
                    pl=data.data
                        optionstring += "<li class='quyuss' onclick='addCodeFun2("+  data.data[i].code+ ",\""+ data.data[i].name+ "\")'>"+ data.data[i].name+ "</li>";

                    $("#getArea").html(optionstring);
                }
                }else{
                    $("#getArea").html('暂无数据'); 
                    codeid=0 
                }

            },
            error: function () {
                $.Huimodalalert('失败！',2000);
            }
        });
    }
    function seachprovicnsfn(e){
    dongtai($(e).val())
}

    //运营经理获取光标
    $("#fen_lsit").focus(function () {
        $("#getArea").show()
    });
    $(document).bind("click",function(e){
        //id为menu的是菜单，id为open的是打开菜单的按钮
        if($(e.target).closest("#getArea").length == 0 && $(e.target).closest("#fen_lsit").length == 0){
            //点击id为menu之外且id不是不是open，则触发
            $("#getArea").hide()
        }
    })
    function addCodeFun2(id,brand_name) {
        codeid=id
        $("#getArea").hide();
        $("#fen_lsit").val(brand_name)
        $("#fen_lsit").attr('porvincode',id)
        $("#fen_lsit").attr('porvinname',brand_name)
        quyua()
    }


    function cancelB() {
        parent.layer.closeAll();
    }
    var wostdd=""
    shezhi()
    function shezhi() {
        $.ajax({
            url:root.sroreinter.houseList,
            cache: false,  //禁用缓存
            type: "POST",
            dataType:'json',
            contentType: "application/json",
            data: JSON.stringify({
                "houseId":sessionStorage.getItem("houstId"),
                "houseName":"",
                "customerName":"",
                "customerId":"",
                "pageNum":"1",
                "pageSize":"10"
            }),
            success: function (data) {
                console.log(data.data.data[0].designated_warehouse)
                wostdd=data.data.data[0].designated_warehouse
                codeid=data.data.data[0].designated_warehouse
                if(data.data.data[0].designated_warehouse!=null||data.data.data[0].designated_warehouse!=""){
                    xuanzhong=1
                }
                console.log(wostdd)
                    $("#house_name").html(data.data.data[0].house_name)
                $("#house_id").html(data.data.data[0].house_id)
                if(data.data.data[0].status==10){
                    $("#status").html("开启")
                }else {
                    $("#status").html("关闭")
                }
                var coustomerIds = "";
                for (var i = 0; i < data.data.data[0].coustomerId.length; i++) {
                    coustomerIds += data.data.data[0].coustomerId[i]+ ",";
                }
                //去掉最后一个逗号(如果不需要去掉，就不用写)
                if (coustomerIds.length > 0) {
                    coustomerIds = coustomerIds.substr(0, coustomerIds.length - 1);
                }
                $("#coustomerId").html(coustomerIds)
                var coustomernames = "";
                for (var i = 0; i < data.data.data[0].coustomerName.length; i++) {
                    coustomernames += data.data.data[0].coustomerName[i]+ ",";
                }
                //去掉最后一个逗号(如果不需要去掉，就不用写)
                if (coustomernames.length > 0) {
                    coustomernames = coustomernames.substr(0, coustomernames.length - 1);
                }

                $("#coustomerName").html(coustomernames)
                $("#group_name").html(data.data.data[0].group_name)
                var loginAccounts = "";
                for (var i = 0; i < data.data.data[0].loginAccount.length; i++) {
                    loginAccounts += data.data.data[0].loginAccount[i]+ ",";
                }
                //去掉最后一个逗号(如果不需要去掉，就不用写)
                if (loginAccounts.length > 0) {
                    loginAccounts = loginAccounts.substr(0, loginAccounts.length - 1);
                }
                $("#loginAccount").html(loginAccounts)




                if(data.data.data[0].designated_warehouse!=0){
                    $.each(pl,function(k,s){
                        if(data.data.data[0].designated_warehouse==s.code){
                            $("#fen_lsit").val(s.name)
                        }

                    })


                        $.ajax({
                            url: root.sroreinter.searchHouseBackendProductList,
                            cache: false,  //禁用缓存
                            type: "POST",
                            dataType:'json',
                            data: {
                                houseId:sessionStorage.getItem("houstId"),
                                designatedWarehouse:wostdd,
                                pageNumber:1,
                                pageSize:30,
                                type:10,
                                skuCode:$("#goodscode").val()
                            },
                            success: function (data) {
                                $("#sp").html(data.data.productList.rowCount)
                                var pk=""
                                if(data.data!=null){
                                    pk=
                                        goodsList(data.data.productList);
                                }else {
                                    goodsList(0);
                                    pk=0
                                }
                                $('.M-box3').pagination({
                                    pageCount:data.data.productList.pageCount,
                                    jump: true,
                                    coping: true,
                                    prevContent: '上页',
                                    nextContent: '下页',
                                    callback: function (api) {
                                        console.log(api)
                                        $.ajax({
                                            url: root.sroreinter.searchHouseBackendProductList,
                                            cache: false,  //禁用缓存
                                            type: "POST",
                                            dataType:'json',
                                            data: {
                                                houseId:sessionStorage.getItem("houstId"),
                                                designatedWarehouse:wostdd,
                                                pageNumber:api.getCurrent(),
                                                pageSize:30,
                                                type:10,
                                                skuCode:$("#goodscode").val()

                                            },
                                            success: function (result) {
                                                goodsList(result.data.productList);
                                            },
                                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                                alert(XMLHttpRequest);
                                            }
                                        });
                                    }
                                });

                            },
                            error: function () {
                                $.Huimodalalert('失败！',2000);
                            }
                        });

                }
            },
            error: function () {
                $.Huimodalalert('失败！',2000);
            }
        });

    }

//导出code
function exportcode() {
    $('#daochu').attr('href','https://'+ window.location.host +'/api/admin/anobodyhouse/exportHouseGoods'+"?houseId="+sessionStorage.getItem("houstId"));

}
    
    //查询code
function querycode(val) {
        if(val==1){
            $.ajax({
                url: root.sroreinter.searchHouseBackendProductList,
                cache: false,  //禁用缓存
                type: "POST",
                dataType:'json',
                data: {
                    houseId:sessionStorage.getItem("houstId"),
                    designatedWarehouse:wostdd,
                    pageNumber:1,
                    pageSize:30,
                    type:10,
                    skuCode:$("#goodscode").val()
                },
                success: function (data) {

                    $("#sp").html(data.data.productList.rowCount)
                    var pk=""
                    if(data.data!=null){
                        pk=""
                        if(data.data.houseResult.skuNum>0){
                            goodsList(data.data.productList);
                            $(".clearfix").css({
                                display: "inline"
                            })
                        }else {
                            if($("#goodscode").val()!=""){
                                goodsList(data.data.productList);
                                $(".clearfix").css({
                                    display: "inline"
                                })
                                $.Huimodalalert('没有找到该商品',2000);
                            }else {
                                goodsList(data.data.productList);
                                $(".clearfix").css({
                                    display: "inline"
                                })
                            }

                        }
                    }else {
                        goodsList(0);
                        $(".clearfix").css({
                            display: "none"
                        })
                        pk=0
                    }
                    $('.M-box3').pagination({
                        pageCount:data.data.productList.pageCount,
                        jump: true,
                        coping: true,
                        prevContent: '上页',
                        nextContent: '下页',
                        callback: function (api) {
                            console.log(api)
                            $.ajax({
                                url: root.sroreinter.searchHouseBackendProductList,
                                cache: false,  //禁用缓存
                                type: "POST",
                                dataType:'json',
                                data: {
                                    houseId:sessionStorage.getItem("houstId"),
                                    designatedWarehouse:wostdd,
                                    pageNumber:api.getCurrent(),
                                    pageSize:30,
                                    type:10,
                                    skuCode:$("#goodscode").val()

                                },
                                success: function (result) {
                                    goodsList(result.data.productList);
                                },
                                error: function (XMLHttpRequest, textStatus, errorThrown) {
                                    alert(XMLHttpRequest);
                                }
                            });
                        }
                    });

                },
                error: function () {
                    $.Huimodalalert('失败！',2000);
                }
            });
        }else {
            //重置code
            $("#goodscode").val("")
            $.ajax({
                url: root.sroreinter.searchHouseBackendProductList,
                cache: false,  //禁用缓存
                type: "POST",
                dataType:'json',
                data: {
                    houseId:sessionStorage.getItem("houstId"),
                    designatedWarehouse:wostdd,
                    pageNumber:1,
                    pageSize:30,
                    type:10,
                    skuCode:""
                },
                success: function (data) {
                    $("#sp").html(data.data.productList.rowCount)
                    var pk=""
                    if(data.data!=null){
                        pk=
                            goodsList(data.data.productList);
                    }else {
                        goodsList(0);
                        pk=0
                    }
                    $('.M-box3').pagination({
                        pageCount:data.data.productList.pageCount,
                        jump: true,
                        coping: true,
                        prevContent: '上页',
                        nextContent: '下页',
                        callback: function (api) {
                            console.log(api)
                            $.ajax({
                                url: root.sroreinter.searchHouseBackendProductList,
                                cache: false,  //禁用缓存
                                type: "POST",
                                dataType:'json',
                                data: {
                                    houseId:sessionStorage.getItem("houstId"),
                                    designatedWarehouse:wostdd,
                                    pageNumber:api.getCurrent(),
                                    pageSize:30,
                                    type:10,
                                    skuCode:""

                                },
                                success: function (result) {
                                    goodsList(result.data.productList);
                                },
                                error: function (XMLHttpRequest, textStatus, errorThrown) {
                                    alert(XMLHttpRequest);
                                }
                            });
                        }
                    });

                },
                error: function () {
                    $.Huimodalalert('失败！',2000);
                }
            });
        }

}

    function goods(){
        $.ajax({
            url: root.sroreinter.searchHouseBackendProductList,
            cache: false,  //禁用缓存
            type: "POST",
            dataType:'json',
            data: {
                houseId:sessionStorage.getItem("houstId"),
                designatedWarehouse:wostdd,
                pageNumber:1,
                pageSize:30,
                type:10,
                skuCode:$("#goodscode").val()
            },
            success: function (data) {
                $("#sp").html(data.data.productList.rowCount)
                var pk=""
                if(data.data!=null){
                    pk=
                        goodsList(data.data.productList);
                }else {
                    goodsList(0);
                    pk=0
                }
                $('.M-box3').pagination({
                    pageCount:data.data.productList.pageCount,
                    jump: true,
                    coping: true,
                    prevContent: '上页',
                    nextContent: '下页',
                    callback: function (api) {
                        console.log(api)
                        $.ajax({
                            url: root.sroreinter.searchHouseBackendProductList,
                            cache: false,  //禁用缓存
                            type: "POST",
                            dataType:'json',
                            data: {
                                houseId:sessionStorage.getItem("houstId"),
                                designatedWarehouse:wostdd,
                                pageNumber:api.getCurrent(),
                                pageSize:30,
                                type:10,
                                skuCode:$("#goodscode").val()

                            },
                            success: function (result) {
                                goodsList(result.data.productList);
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                alert(XMLHttpRequest);
                            }
                        });
                    }
                });

            },
            error: function () {
                $.Huimodalalert('失败！',2000);
            }
        });

    }
    //商品设置

    var dataSource = new Array();
    //table的数据源
    var table; //table对象
    dataSource = [];

    window.onload = function(){
        sessionStorage.setItem("wareHouseCode", 1)
    }

    function goodsList(data) {
        console.log(data)
        if(dataSource.length>0){
            dataSource.splice(0, dataSource.length); //清空数组
        }
        if(data.data!=null){
            var datashu =data.startRow+1;
            $.each(data.data, function(i, field) {
                var datashus = datashu++
                var rowData = new Array();
                rowData.push(field.sku_code);
                rowData.push(field.sku_img);
                rowData.push(field.sku_name); //商品名称
                rowData.push(field.sku_specs);
                rowData.push(field.brand);
                rowData.push(field.product_price);
                rowData.push(field.unit);
                rowData.push(field.available_stock);
                rowData.push(field.total_stock);
                rowData.push(field.position);
                rowData.push(field.created_at);
                rowData.push(field.house_product_id);
                rowData.push(field.house_id);
                rowData.push(datashus);
                rowData.push(field.skuSign);
                dataSource.push(rowData);
            });
        }
        initDataTable(dataSource);

        function initDataTable(dataSource) {
            var dttable = $('#datatable').dataTable( ); // 初始化dataTable，清空上一个值
            dttable.fnClearTable(); //清空一下table
            dttable.fnDestroy(); //还原初始化了的datatable
            $("#datatable").DataTable({
                "autoWidth": false,
                "order": [[ 8, "desc" ]],
                "ordering": false,
                "searching": false,
                "paging": false,
                "retrieve": false,
                "destroy": false,
                "bAutoWidth": false,
                "bLengthChange": false,
                "aLengthMenu":[30,20,30],
                "oLanguage": {
                    "sLengthMenu": "每页显示 _MENU_ 条记录",
                    "sZeroRecords": "抱歉， 没有找到",
                    "sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
                    "sInfoEmpty": "没有数据",
                    "sInfoFiltered": "(从 _MAX_ 条数据中检索)",
                    "oPaginate": {
                        "sFirst": "首页",
                        "sPrevious": "前一页",
                        "sNext": "后一页",
                        "sLast": "尾页"
                    },
                    "sZeroRecords": "没有检索到数据",
                    "sProcessing": "<img src='./loading.gif' />"
                },
                data: dataSource,
                columnDefs: [
                    {
                        "visible": true,
                        "targets": 0
                    },
                    {
                        "render": function (data, type, row, meta) {
                            var val = row[13]
                            if (val == undefined) {
                                val = ''
                            }
                            return val;
                        },
                        "targets": 0
                    },
                    {
                        "render": function (data, type, row, meta) {
                            var val = row[0]
                            if (val == undefined) {
                                val = ''
                            }
                            return val;
                        },
                        "targets": 1
                    },
                    {
                        "render": function(data, type, row, meta) {
                            var val = '<img onclick="picShow(\'查看图片\',\'../goods/picShow.html\',\'' + row[1] + '\')" title="" width="50" height="50" src="' + row[1] + '" id="myImg" class="mr-10">';
                            return val;
                        },
                        "targets": 2
                    },
                    {
                        "render": function (data, type, row, meta) {
                            var val = ""

                            if(row[14]==10){
                                val="<div class='colour'>"+row[2]+"<div>"
                            }else {
                                val=row[2]
                            }
                            return val;
                        },
                        "targets": 3
                    },
                    {
                        "render": function (data, type, row, meta) {
                            var val = row[3]
                            if (val == undefined) {
                                val = ''
                            }
                            return val;
                        },
                        "targets": 4
                    },
                    {
                        "render": function (data, type, row, meta) {
                            var val = row[4]
                            if (val == undefined) {
                                val = ''
                            }
                            return val;
                        },
                        "targets": 5
                    },
                    {
                        "render": function (data, type, row, meta) {

                            var f = Math.round(row[5]*100)/100;
                            var s = f.toString();
                            var rs = s.indexOf('.');
                            if (rs < 0) {
                                rs = s.length;
                                s += '.';
                            }
                            while (s.length <= rs + 2) {
                                s += '0';
                            }
                            return s;
                        },
                        "targets":6
                    },
                    {
                        "render": function (data, type, row, meta) {
                            var val = row[6]
                            if (val == undefined) {
                                val = ''
                            }
                            return val;
                        },
                        "targets": 7
                    },
                    {
                        "render": function (data, type, row, meta) {
                            var val = row[7]
                            if (val == undefined) {
                                val = ''
                            }
                            return val;
                        },
                        "targets": 8
                    },
                    {
                        /*虚拟库存上限*/
                        "render": function(data, type, row, meta) {
                            var isSpecialSku = row[8]==null?true:false ;
                            var classStyle = isSpecialSku?"Hui-iconfont f-ricon-edit  hide":"Hui-iconfont f-ricon-edit" ;

                                var val = '<span id="' + row[0] + '">' + row[8] + '</span>&nbsp;<input value="' + row[8] + '" class="hide"  id="changeNum' + row[0] + '">' +
                                    '<span id="editorIcon'+row[0]+'" class="'+classStyle+'" onclick="edit_stock(\''+row[0]+'\')">&#xe6df; ' +
                                    '</span>  <button id="change'+row[0]+'" type="button" onclick="isChange(\''+row[0]+'\',\''+row[12]+'\')" class="hide" >确定</button> ' +
                                    ' <button id="cancel'+row[0]+'"  type="button"  class="hide" onclick="isCancel(\''+row[0]+'\')">取消</button>';
                                return val;

                        },
                        "targets": 9
                    },
                    {
                        /*虚拟库存上限*/
                        "render": function(data, type, row, meta) {
                            var isSpecialSku = row[9]==null?true:false ;
                            var classStyle = isSpecialSku?"Hui-iconfont f-ricon-edit  hide":"Hui-iconfont f-ricon-edit " ;

                            var val = '<span id="' + row[11] + '">' + row[9] + '</span>&nbsp;<input value="' + row[9] + '" class="hide" id="changeNum'+row[11]+'">' +
                                '<span id="editorIcon'+row[11]+'" class="'+classStyle+'" onclick="edit_stock(\''+row[11]+'\')">&#xe6df; ' +
                                '</span>  <button id="change'+row[11]+'" type="button" onclick="isChange2(\''+row[11]+'\',\''+row[0]+'\',\''+row[12]+'\')" class="hide" >确定</button> ' +
                                ' <button id="cancel'+row[11]+'"  type="button"  class="hide" onclick="isCancel(\''+row[11]+'\')">取消</button>';
                            return val;
                        },
                        "targets": 10
                    },
                    {
                        "render": function (data, type, row, meta) {
                            var val = row[10]
                            if (val == undefined) {
                                val = ''
                            }
                            if (val == "1000-01-01 00:00") {
                                val = ''
                            }
                            return val;
                        },
                        "targets": 11
                    },
                    {
                        "render": function(data, type, row, meta) {

                                var val = '<a onclick="deleteok(\''+row[11]+'\')">删除</a>';
                                return val;

                        },
                        "targets": 12
                    }
                ],
            });
        };
        $('.colour').parent().parent().css('background-color','pink');
    }

    //可超卖库存修改
    function edit_stock(id,value) {
        console.log("1111111111")
        $('#'+id+'').addClass('hide');
        $('#changeNum'+id+'').removeClass('hide');
        console.log("22222222222")
        $('#change'+id+'').removeClass('hide');
        $('#cancel'+id+'').removeClass('hide');
        $('#editorIcon'+id+'').addClass('hide');
        $('#changeNum'+id+'').val($('#'+id+'').html());
    }
    //取消
    function isCancel(id,oldVal) {
        console.log($('#'+id+'').html())
        $('#'+id+'').removeClass('hide');
        $('#changeNum'+id+'').addClass('hide');
        $('#change'+id+'').addClass('hide');
        $('#cancel'+id+'').addClass('hide');

        $('#changeNum'+id+'').val($('#'+id+'').html());
        $('#editorIcon'+id+'').removeClass('hide');
    }
//修改总库存
    function isChange(id,houseIds) {
        $('#'+id+'').removeClass('hide');
        $('#changeNum'+id+'').addClass('hide');
        $('#change'+id+'').addClass('hide');
        $('#cancel'+id+'').addClass('hide');
        $('#editorIcon'+id+'').removeClass('hide');
        var virtualStockLimit=$('#changeNum'+id+'').val();

        var stock_data = {
            houseId:houseIds,
            skuCode:id,
            stockNum:virtualStockLimit,
            productSpace:""
        }
        var succCallBack = function (data, status, response) {
            if(data.errorCode==0){
                quyua()
                $('#'+id+'').html(virtualStockLimit);
                document.getElementById('virtualStockId'+id+'').innerHTML = virtualStockLimit;
            }else {
                $.Huimodalalert(data.msg,2000);
            }
        };
        return web.doAjax('https://'+ window.location.host +'/api/admin/anobodyhouse/updateStockNum', 'post', stock_data, succCallBack);
    }
    //修改仓位
    function isChange2(id,skucode,hostid) {
        $('#'+id+'').removeClass('hide');
        $('#changeNum'+id+'').addClass('hide');
        $('#change'+id+'').addClass('hide');
        $('#cancel'+id+'').addClass('hide');
        $('#editorIcon'+id+'').removeClass('hide');
        var virtualStockLimit=$('#changeNum'+id+'').val();

        var stock_data = {
            houseId:hostid,
            skuCode:skucode,
            stockNum:"",
            productSpace:virtualStockLimit
        }
        var succCallBack = function (data, status, response) {
            if(data.errorCode==0){
                quyua()
                $('#'+id+'').html(virtualStockLimit);
                document.getElementById('virtualStockId'+id+'').innerHTML = virtualStockLimit;
            }else {
                $.Huimodalalert(data.msg,2000);
            }
        };
        return web.doAjax('https://'+ window.location.host +'/api/admin/anobodyhouse/updateStockNum', 'post', stock_data, succCallBack);
    }
    function deleteok(productIds) {

        var curInd = layer.confirm('<span id="status" style="width:200px;height:100px;resize: none;" maxlength="200" >删除后云仓将不可售卖</span>', {title:'提示',btn: ['确定', '取消']}, function(index){


            $.ajax({
                url: 'https://'+ window.location.host +'/api/admin/anobodyhouse/deleteHouseProduct',
                cache: false,  //禁用缓存
                type: "POST",
                dataType:'json',
                data: {
                    productId:productIds,

                },
                success: function (data) {
                    shezhi()
                },
                error: function () {
                    $.Huimodalalert('失败！',2000);
                }
            });
            layer.close(curInd);
        },function(){
            layer.close(curInd);

        });

    }


    //区域选中

    function quyu() {
        if(codeid==0){
            $.Huimodalalert('请选择指定价格省份!',2000);
            return false;
        }
        $.ajax({
            url: root.sroreinter.updateHouseArea,
            cache: false,  //禁用缓存
            type: "POST",
            dataType:'json',
            timeout: 2 * 60 * 1000,
            data: {
                houseId:sessionStorage.getItem("houstId"),
                designatedWarehouse: codeid,
            },
            success: function (data) {

                if(data.errorCode==0){
                    xuanzhong=1
                    $.Huimodalalert('指定价格省份设置成功!',2000);
                    quyuaqq()
                }else {
                    $.Huimodalalert(data.msg,2000);

                }

            },
            error: function () {
                $.Huimodalalert('失败！',2000);
            }
        });
    }

    function quyua() {
        $.ajax({
            url: root.sroreinter.searchHouseBackendProductList,
            cache: false,  //禁用缓存
            type: "POST",
            dataType:'json',
            data: {
                houseId:sessionStorage.getItem("houstId"),
                designatedWarehouse: codeid,
                pageNumber:1,
                pageSize:30,
                type:10,
                skuCode:$("#goodscode").val()

            },
            success: function (data) {
                if(data.errorCode==0){
                    xuanzhong=0
                }
                var pk=""
                if(data.data!=null){
                    pk=
                        goodsList(data.data.productList);
                }else {
                    goodsList(0);
                    pk=0
                }
                $('.M-box3').pagination({
                    pageCount:data.data.productList.pageCount,
                    jump: true,
                    coping: true,
                    prevContent: '上页',
                    nextContent: '下页',
                    callback: function (api) {
                        console.log(api)
                        $.ajax({
                            url: root.sroreinter.searchHouseBackendProductList,
                            cache: false,  //禁用缓存
                            type: "POST",
                            dataType:'json',
                            data: {
                                houseId:sessionStorage.getItem("houstId"),
                                designatedWarehouse: codeid,
                                pageNumber:api.getCurrent(),
                                pageSize:30,
                                type:10,
                                skuCode:$("#goodscode").val()

                            },
                            success: function (result) {
                                goodsList(result.data.productList);
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                alert(XMLHttpRequest);
                            }
                        });
                    }
                });

            },
            error: function () {
                $.Huimodalalert('失败！',2000);
            }
        });
    }
function quyuaqq() {
    $.ajax({
        url: root.sroreinter.searchHouseBackendProductList,
        cache: false,  //禁用缓存
        type: "POST",
        dataType:'json',
        data: {
            houseId:sessionStorage.getItem("houstId"),
            designatedWarehouse: codeid,
            pageNumber:1,
            pageSize:30,
            type:10,
            skuCode:$("#goodscode").val()
        },
        success: function (data) {
            var pk=""
            if(data.data!=null){
                pk=
                    goodsList(data.data.productList);
            }else {
                goodsList(0);
                pk=0
            }
            $('.M-box3').pagination({
                pageCount:data.data.productList.pageCount,
                jump: true,
                coping: true,
                prevContent: '上页',
                nextContent: '下页',
                callback: function (api) {
                    console.log(api)
                    $.ajax({
                        url: root.sroreinter.searchHouseBackendProductList,
                        cache: false,  //禁用缓存
                        type: "POST",
                        dataType:'json',
                        data: {
                            houseId:sessionStorage.getItem("houstId"),
                            designatedWarehouse: codeid,
                            pageNumber:api.getCurrent(),
                            pageSize:30,
                            type:10,
                            skuCode:$("#goodscode").val()

                        },
                        success: function (result) {
                            goodsList(result.data.productList);
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            alert(XMLHttpRequest);
                        }
                    });
                }
            });

        },
        error: function () {
            $.Huimodalalert('失败！',2000);
        }
    });
}



function tiao(title,url) {
    if($("#fen_lsit").val()=="" || xuanzhong==0){

        var curInd = layer.confirm('<span id="status" style="width:200px;height:100px;resize: none;" maxlength="200" >请选中指定价格区域之后添加商品！</span>', {title:'提示',btn: ['确定']}, function(index){

            layer.close(curInd);
        });
        return false;
    }
    sessionStorage.setItem("houstIdss",sessionStorage.getItem("houstId"))
    var index = layer.open({
        type: 2,
        title: title,
        content: url
    });
    layer.full(index);
}

//查看低下限商品
    function viewItem() {
        $.ajax({
            url: root.sroreinter.searchHouseBackendProductList,
            cache: false,  //禁用缓存
            type: "POST",
            dataType:'json',
            data: {
                houseId:sessionStorage.getItem("houstId"),
                designatedWarehouse:wostdd,
                pageNumber:1,
                pageSize:30,
                type:10,
                skuCode:$("#goodscode").val(),
                "checkStock":1
            },
            success: function (data) {

                $("#sp").html(data.data.productList.rowCount)
                var pk=""
                if(data.data!=null){
                    pk=""
                    if(data.data.houseResult.skuNum>0){
                        goodsList(data.data.productList);
                        $(".clearfix").css({
                            display: "inline"
                        })
                    }else {
                        if($("#goodscode").val()!=""){
                            goodsList(data.data.productList);
                            $(".clearfix").css({
                                display: "inline"
                            })
                            $.Huimodalalert('没有找到该商品',2000);
                        }else {
                            goodsList(data.data.productList);
                            $(".clearfix").css({
                                display: "inline"
                            })
                        }

                    }
                }else {
                    goodsList(0);
                    $(".clearfix").css({
                        display: "none"
                    })
                    pk=0
                }
                $('.M-box3').pagination({
                    pageCount:data.data.productList.pageCount,
                    jump: true,
                    coping: true,
                    prevContent: '上页',
                    nextContent: '下页',
                    callback: function (api) {
                        console.log(api)
                        $.ajax({
                            url:root.sroreinter.searchHouseBackendProductList,
                            cache: false,  //禁用缓存
                            type: "POST",
                            dataType:'json',
                            data: {
                                houseId:sessionStorage.getItem("houstId"),
                                designatedWarehouse:wostdd,
                                pageNumber:api.getCurrent(),
                                pageSize:30,
                                type:10,
                                skuCode:$("#goodscode").val(),
                                "checkStock":1
                            },
                            success: function (result) {
                                goodsList(result.data.productList);
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                alert(XMLHttpRequest);
                            }
                        });
                    }
                });

            },
            error: function () {
                $.Huimodalalert('失败！',2000);
            }
        });
    }
    //
//导出低下限商品
function exportGoods() {
    $('#exportGood').attr('href','https://'+ window.location.host +'/api/admin/anobodyhouse/exportHouseGoods'+"?houseId="+sessionStorage.getItem("houstId")+"&checkStock="+Number(1));

}
</script>
</body>
</html>